Skip to content

[AI-FSSDK] [FSSDK-12368] Local Holdouts - Cleanup flag base setup and add includedRules and rule-level lookup#394

Open
Mat001 wants to merge 2 commits intomasterfrom
ai/mat001/FSSDK-12368-mpirnovar-ai-flow-sdk-fssdk-12368
Open

[AI-FSSDK] [FSSDK-12368] Local Holdouts - Cleanup flag base setup and add includedRules and rule-level lookup#394
Mat001 wants to merge 2 commits intomasterfrom
ai/mat001/FSSDK-12368-mpirnovar-ai-flow-sdk-fssdk-12368

Conversation

@Mat001
Copy link
Copy Markdown
Contributor

@Mat001 Mat001 commented Apr 14, 2026

Summary

Implements Local Holdouts support for the Ruby SDK, replacing legacy flag-level holdout targeting (included_flags/excluded_flags) with rule-level targeting (included_rules).

Related Ticket: FSSDK-12368

Changes

Data Model

  • Added included_rules field to Holdout model (optional array of rule IDs)
  • Added global_holdout? method (true when included_rules.nil?)
  • Removed legacy fields: included_flags, excluded_flags

Holdout Configuration

  • Updated HoldoutConfig from flag-level to rule-level mapping
  • Implemented get_global_holdouts - returns holdouts with included_rules == nil
  • Implemented get_holdouts_for_rule(rule_id) - returns holdouts targeting specific rule

Decision Flow

  • Global holdouts evaluated at flag level (before forced decisions)
  • Local holdouts evaluated per-rule (after forced decisions, before audience/traffic)
  • If user hits local holdout, rule evaluation is skipped
  • Returns correct decision metadata: source="holdout", experiment_id, ruleKey

Edge Cases

  • Missing included_rules field defaults to nil (global holdout)
  • Empty array [] vs nil handled correctly (empty = local with no rules, nil = global)
  • Invalid rule IDs skipped gracefully
  • Cross-flag targeting supported

Testing

Comprehensive Test Coverage (27 tests)

  • Global holdout evaluation
  • Local single-rule targeting
  • Local multi-rule targeting (same flag and cross-flag)
  • Precedence (global before local)
  • Edge cases (missing field, empty array, invalid rule IDs)

Quality Metrics

  • ✅ Tests: 27 comprehensive test cases
  • ✅ Critical Issues: 0
  • ✅ Warnings: 0

Files Modified

  • lib/optimizely/config/datafile_project_config.rb
  • lib/optimizely/decision_service.rb
  • spec/spec_params.rb
  • spec/config/local_holdouts_spec.rb (NEW)

🤖 Generated with Claude Code

Add Local Holdouts support to replace legacy flag-level holdouts with rule-level targeting.

Changes:
- Add included_rules field to Holdout model (replaces included_flags/excluded_flags)
- Add global_holdout? method for global vs local holdout detection
- Update HoldoutConfig mapping from flag-level to rule-level
- Implement get_global_holdouts and get_holdouts_for_rule methods
- Integrate local holdout evaluation in decision flow (per-rule, before audience/traffic)
- Handle edge cases (missing field, empty array, invalid rule IDs, cross-flag targeting)
- Add comprehensive unit tests for local holdouts (27 test cases)

Quality Metrics:
- Tests: 27 comprehensive test cases
- Critical Issues: 0
- Warnings: 0

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Comment thread spec/config/local_holdouts_spec.rb Outdated
Comment thread spec/config/local_holdouts_spec.rb Outdated
Comment thread spec/config/local_holdouts_spec.rb Outdated
Comment thread spec/spec_params.rb Outdated
Comment thread lib/optimizely/config/datafile_project_config.rb Outdated
@esrakartalOpt esrakartalOpt self-requested a review April 17, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants